﻿@model Think9.Models.TbBasicEntity
@{ ViewBag.Title = "Index";
    Layout = "~/Areas/Shared/_LayuiForm.cshtml"; }

<form class="layui-form" lay-filter="formEdit">
    <input style="display: none" name="TbId" id="TbId" value="@Model.TbId">
    <div class="layui-form-item">
        <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <div class="layui-input-inline">
                是否显示
            </div>
            <div class="layui-input-inline">
                按钮标题
            </div>
            <div class="layui-input-inline">
                提醒字符
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-form-item">
            <label class="layui-form-label">附件按钮</label>
            <div class="layui-input-inline">
                <input type="hidden" name="ButAtt" value="0">
                <input type="checkbox" name="ButAtt" id="ButAtt" lay-skin="primary" title="显示" value="1">
            </div>
            <div class="layui-input-inline">
                <input type="text" name="ButAttTxt" id="ButAttTxt" placeholder="按钮标题" autocomplete="off" class="layui-input"  style="width:100px" maxlength="10">
            </div>
            <div class="layui-input-inline">
                <input type="text" name="ButAttWarn" id="ButAttWarn" placeholder="提醒字符" autocomplete="off" class="layui-input" style="width:400px" maxlength="100">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-form-item">
            <label class="layui-form-label">保存按钮</label>
            <div class="layui-input-inline">
                <input type="hidden" name="ButEdit" value="0">
                <input type="checkbox" name="ButEdit" id="ButEdit" lay-skin="primary" title="显示" value="1" disabled="disabled">
            </div>
            <div class="layui-input-inline">
                <input type="text" name="ButEditTxt" id="ButEditTxt" placeholder="按钮标题" autocomplete="off" class="layui-input"  style="width:100px" maxlength="10">
            </div>
            <div class="layui-input-inline">
                <input type="text" name="ButEditWarn" id="ButEditWarn" placeholder="提醒字符" autocomplete="off" class="layui-input" style="width:400px" maxlength="100">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-form-item">
            <label class="layui-form-label">转交按钮</label>
            <div class="layui-input-inline">
                <input type="hidden" name="ButNext" value="0">
                <input type="checkbox" name="ButNext" id="ButNext" lay-skin="primary" title="显示" value="1">
            </div>
            <div class="layui-input-inline">
                <input type="text" name="ButNextTxt" id="ButNextTxt" placeholder="按钮标题" autocomplete="off" class="layui-input"  style="width:100px" maxlength="10">
            </div>
            <div class="layui-input-inline">
                <input type="text" name="ButNextWarn" id="ButNextWarn" placeholder="提醒字符" autocomplete="off" class="layui-input" style="width:400px" maxlength="100">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-form-item">
            <label class="layui-form-label">结束按钮</label>
            <div class="layui-input-inline">
                <input type="hidden" name="ButFinish" value="0">
                <input type="checkbox" name="ButFinish" id="ButFinish" lay-skin="primary" title="显示" value="1">
            </div>
            <div class="layui-input-inline">
                <input type="text" name="ButFinishTxt" id="ButFinishTxt" placeholder="按钮标题" autocomplete="off" class="layui-input" style="width:100px" maxlength="10">
            </div>
            <div class="layui-input-inline">
                <input type="text" name="ButFinishWarn" id="ButFinishWarn" placeholder="提醒字符" autocomplete="off" class="layui-input" style="width:400px" maxlength="100">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="edit">编辑</button>
        </div>
    </div>
</form>

<script>
	layui.use(["table", 'form', "exLayer", "exUtils"], function () {
		let form = layui.form;
		let exLayer = layui.exLayer;
		let exUtils = layui.exUtils;
		let table = layui.table;

		let $ = layui.$;
		form.render();

        getFormVal();

		form.val("formEdit", {
			"ButAttTxt": "@Model.ButAttTxt"
            ,"ButEditTxt": "@Model.ButEditTxt"
            ,"ButNextTxt": "@Model.ButNextTxt"
            , "ButFinishTxt": "@Model.ButFinishTxt"

            ,"ButAttWarn": "@Model.ButAttWarn"
            ,"ButEditWarn": "@Model.ButEditWarn"
            ,"ButNextWarn": "@Model.ButNextWarn"
            ,"ButFinishWarn": "@Model.ButFinishWarn"
        });
        function getFormVal() {
			if (@Model.ButAtt == "1") {
                $('#ButAtt').attr("checked", true);
			}
			else {
                $("#ButAtt").removeAttr("checked");
			}

			if (@Model.ButNext == "1") {
                $('#ButNext').attr("checked", true);
			}
			else {
                $("#ButNext").removeAttr("checked");
			}

			if (@Model.ButFinish == "1") {
                $('#ButFinish').attr("checked", true);
			}
			else {
                $("#ButFinish").removeAttr("checked");
			}

            $('#ButEdit').attr("checked", true);
		}

		form.on("submit(edit)", function (data) {
            exUtils.ajax("/SysTable/TbBasic/EditTbBut", "post", { model: data.field, tbid: $("#TbId").val()}, true).done(function (response) {
				exLayer.greenTickMsg(response.message, function () {
					parent.layer.close(parent.layer.getFrameIndex(window.name));
				});
			}).fail(function (error) {
				console.log(error);
			});
			return false;
		});
	})
</script>